package com.sunmouse.toolkit.fragment.media;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sunmouse.toolkit.R;
import com.sunmouse.toolkit.fragment.BaseFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * A simple {@link Fragment} subclass.
 */
public class MsgFragment extends BaseFragment {


    @BindView(R.id.receive_tv)
    TextView receiveTv;
    Unbinder unbinder;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.activity_msg, container, false);
        unbinder = ButterKnife.bind(this, v);
        return v;
    }


    @Override
    public void init() {
        super.init();
        this.mBundle = getArguments();
        String action = mBundle.getString("action");
        String mineType = mBundle.getString("type");
        String msg = mBundle.getString("msg");

        if (action.equals(Intent.ACTION_SEND) && !TextUtils.isEmpty(mineType)) {
            if (mineType.equals("text/plain")) {
                this.receiveTv.setText(msg);
                return;
            }

            if (mineType.startsWith("image/")) {

                return;
            }
            return;
        }

        //handle multi image
        if (action.equals(Intent.ACTION_SEND_MULTIPLE) && !TextUtils.isEmpty(mineType)) {

        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
